/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package members;

import java.security.MessageDigest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;

/**
 *
 * @author gjun
 */
public class UpdateMemberProcess {
    
    private String accountName;
    private String accountPassword;
    private String accountRealName;
    private String sex;
    private String tel;  
    private String email;
    private String county;
    private String region;
    private String address;
    
    public UpdateMemberProcess() {
    }
    
    public String execute() throws Exception {
        HttpServletRequest request=ServletActionContext.getRequest();        
        HttpSession session=request.getSession();
        
        this.accountName=session.getAttribute("LoginName").toString();
        
        //雜湊密碼
        MessageDigest md = MessageDigest.getInstance("SHA-256");        
        byte[] bb=md.digest(accountPassword.getBytes());
        
        db.NWDB mydb=new db.NWDB();        
        mydb.updateNewMember(accountName, bb, accountRealName, sex, tel, email, county, region, address);
        mydb.dbClose();
        
        return "success";
    }

    /**
     * @return the accountName
     */
    public String getAccountName() {
        return accountName;
    }

    /**
     * @param accountName the accountName to set
     */
    public void setAccountName(String accountName) {
        this.accountName = accountName;
    }

    /**
     * @return the accountPassword
     */
    public String getAccountPassword() {
        return accountPassword;
    }

    /**
     * @param accountPassword the accountPassword to set
     */
    public void setAccountPassword(String accountPassword) {
        this.accountPassword = accountPassword;
    }

    /**
     * @return the accountRealName
     */
    public String getAccountRealName() {
        return accountRealName;
    }

    /**
     * @param accountRealName the accountRealName to set
     */
    public void setAccountRealName(String accountRealName) {
        this.accountRealName = accountRealName;
    }

    /**
     * @return the sex
     */
    public String getSex() {
        return sex;
    }

    /**
     * @param sex the sex to set
     */
    public void setSex(String sex) {
        this.sex = sex;
    }

    /**
     * @return the county
     */
    public String getCounty() {
        return county;
    }

    /**
     * @param county the county to set
     */
    public void setCounty(String county) {
        this.county = county;
    }

    /**
     * @return the region
     */
    public String getRegion() {
        return region;
    }

    /**
     * @param region the region to set
     */
    public void setRegion(String region) {
        this.region = region;
    }

    /**
     * @return the address
     */
    public String getAddress() {
        return address;
    }

    /**
     * @param address the address to set
     */
    public void setAddress(String address) {
        this.address = address;
    }

    /**
     * @return the email
     */
    public String getEmail() {
        return email;
    }

    /**
     * @param email the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }
    
    /**
     * @return the tel
     */
    public String getTel() {
        return tel;
    }

    /**
     * @param tel the tel to set
     */
    public void setTel(String tel) {
        this.tel = tel;
    }
}
